/**
 * MultiMessageHandler.java 2020/5/13 7:38 下午 Copyright ©2020 www.bmsoft.com.cn All rights reserved.
 * PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package remoting.channel;

import common.exception.RemotingException;

/**
 * File：MultiMessageHandler.java<br>
 * Title: <br>
 * Description: <br>
 * Company: www.treefinance.com.cn <br>
 * @author heyouchi
 * Date: 2020/5/13
 */
public class MultiMessageHandler extends AbstractChannelHandlerDelegate {

  public MultiMessageHandler(ChannelHandler handler) {
    super(handler);
  }

  @SuppressWarnings("unchecked")
  @Override
  public void received(Channel channel, Object message) throws RemotingException {
    if (message instanceof MultiMessage) {
      MultiMessage list = (MultiMessage) message;
      for (Object obj : list) {
        handler.received(channel, obj);
      }
    } else {
      handler.received(channel, message);
    }
  }
}
